<template>
  <div>
    <el-form ref="applyForm" :model="formItem" label-width="100px" size="mini">
      <el-row>
        <el-col :span="24">
          <el-card class="box-card">
            <div slot="header" class="clearfix">
              <span>库管确认</span>
            </div>
            <div>
              <el-table
                :loading="loading"
                :data="insideTableData"
              >
                <el-table-column v-for="column in insideColumns" :key="column.key" :label="column.title" :prop="column.key" :sortable="column.sortable">
                  <template slot-scope="scope">
                    <column-render :render="column.render" :row="scope.row" :column="column" />
                  </template>
                </el-table-column>
              </el-table>
            </div>
          </el-card>
        </el-col>
      </el-row>
    </el-form>

  </div>
</template>
<script>
import databind from '@neu/biz-core/mixins/databind'
import {
  listStockSelect
} from '@neu/dcam-ui/api/spareconsume'

const formItem = {
  requirePerson: null
}
export default {
  mixins: [databind],
  props: {
    taskId: {
      required: false,
      type: String,
      default: 'NULL'
    },
    workOrderNum: {
      required: false,
      type: String,
      default: ''
    }
  },
  data() {
    return {
      r: listStockSelect,
      persons: [],
      formItem: {
        ...formItem
      },
      insideColumns: [
        {
          title: '货品编号',
          key: 'storckNumber'
        }, {
          title: '备品备件分类',
          key: 'spareTypeName'
        },
        {
          title: '规格型号',
          key: 'specification'
        },
        {
          title: 'SN',
          key: 'sn'
        },
        {
          title: '存放库房',
          key: 'storehouseName'
        },
        {
          title: '单价',
          key: 'unitPrice'
        },
        {
          title: '货品来源',
          key: 'source',
          render: (h, params) => {
            let sourceDesc = ''
            if (params.row.source === 'new') {
              sourceDesc = '合同采购'
            } else if (params.row.source === 'back') {
              sourceDesc = '退库利旧'
            }
            return h('span', [
              h('el-tag', sourceDesc)
            ])
          }
        }
      ]
    }
  },
  created() {
    const parameter = {
      's_workOrderNum': this.workOrderNum,
      's_taskId': this.taskId
    }
    this.filter(parameter)
  }
}
</script>
